﻿using Hotel.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotel.DAL
{
    public class AdminDAL
    {
        HotelDBContext db;
        public AdminDAL(HotelDBContext db)
        {
            this.db = db;
        }
        public decimal Login(string UserNmae, string UsetPwd)
        {
            try
            {   //判断用户名是否存在
                var count = db.Admins.Where(x => x.UserName == UserNmae).Count();
                if (count == 0)
                {
                    return -1;//表示用户名不存在
                }
                else 
                {
                    var c = db.Admins.Where(x => x.UsrPwd == UsetPwd).Count();
                    if (c == 0)
                    {
                        return -2;
                    }
                    else 
                    {
                        var info = db.Admins.Where(x => x.UserName == UserNmae && x.UsrPwd == UsetPwd).Count();
                        return info;
                    }
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
        public int Logint1()
        {
            return 1;
        }
    }
}
